package com.example.x5webviewdemo.service;

import android.app.IntentService;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

import androidx.annotation.Nullable;

import com.tencent.smtt.sdk.QbSdk;

import static android.provider.ContactsContract.Intents.Insert.ACTION;

/**
 * @作者: njb
 * @时间: 2019/11/8 10:32
 * @描述: IntentService启动优化
 */
public class MyIntentService extends IntentService {



    public MyIntentService() {
        super("myIntentService");
    }

    public static void start(Context context) {
        Intent intent = new Intent(context, MyIntentService.class);
        intent.setAction(ACTION);
        context.startService(intent);
    }

    @Override
    protected void onHandleIntent(@Nullable Intent intent) {
        //处理第三方库初始化
        initX5WebView();
    }

    private void initX5WebView(){
        QbSdk.PreInitCallback cb = new QbSdk.PreInitCallback() {

            @Override
            public void onViewInitFinished(boolean arg0) {
                // TODO Auto-generated method stub
                //x5內核初始化完成的回调，为true表示x5内核加载成功，否则表示x5内核加载失败，会自动切换到系统内核。
                Log.d("app", " onViewInitFinished is " + arg0);
            }

            @Override
            public void onCoreInitFinished() {
                // TODO Auto-generated method stub
            }
        };
        //x5内核初始化接口
        QbSdk.initX5Environment(getApplicationContext(),  cb);
    }
}
